package algorithm.hash;

/**
 * @author bingo
 * @Description
 * @Date 2018/7/15
 */
public class Example {

    public static int getFirstIndex(String str){

        int[]  front = new int[24];
        for(int i = 0; i<str.length();i++){
            front[str.charAt(i)-'a']++;
        }
        for(int i=0;i<str.length();i++){
            if(front[str.charAt(i)-'a']==1){
                return i;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        System.out.println(Example.getFirstIndex("fangf"));
    }
}
